package com.bootdo.front.controller;

import com.bootdo.common.annotation.Log;
import com.bootdo.common.utils.R;
import com.bootdo.front.vo.Result;
import com.bootdo.system.domain.RoleDO;
import com.bootdo.system.domain.UserDO;
import com.bootdo.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/userInfo")
@RestController
public class UserInfoContorller {
    @Autowired
    UserService userService;

    @Log("更新用户")
    @PostMapping("/update")
    @ResponseBody
    Result update(@RequestBody UserDO user) {
        if (userService.update(user) > 0) {
            return Result.ok();
        }
        return Result.error();
    }


    @Log("获取用户信息")
    @GetMapping("/get/{id}")
    Result edit(@PathVariable("id") Long id) {
        UserDO userDO = userService.getInfo(id);
        userDO.setPassword(null);
        return Result.ok(userDO);
    }



}
